<?php

class Core_Backend_Component_Global_View_Module_Create extends Core_Backend_Share_View_Form {

    public function initialize() {
        $this->setTemplatePath('edit');
    }

    protected function buildNavigation($navigation) {

        $navigation->addLabel($this->__f('share.title.create', '{global.label.module}'));
    }

    protected function buildToolbar($toolbar) {
        $toolbar->addButton($this->__('share.button.back'), "setLocation('{$this->getHistoryUrl('global/module/index')}')");
        $toolbar->addButton($this->__('share.button.apply'), "Kdf.Ui.getForm('" . $this->getForm()->getId() . "').apply()");
        $toolbar->addButton($this->__('share.button.save'), "Kdf.Ui.getForm('" . $this->getForm()->getId() . "').save()");

    }

    protected function buildForm($form) {
        $entity = $this->getModel();
        $form->setAction($this->getUrl())
                ->setId('module_form')
                ->addHiddenField('id', 'module[id]')
                ->addTextboxField($this->__('share.label.name'), 'name', 'module[name]', TRUE)
                ->addMultiRule('required')->getForm()
                ->addTextboxField($this->__('global.label.position'), 'position', 'module[position]', TRUE)
                ->addMultiRule('required')->getForm()
                ->addSelectField($this->__('global.label.area'), 'area_id', 'module[area_id]', TRUE)
                ->addMultiRule('required')->setOption('--', 0)
                ->getForm();
        if (!is_null($entity)) {
            $form->bindData($entity->getAllData());
        }
        parent::buildForm($form);
    }

 

}

